using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

using SchemaProvider;

namespace OracleSchemaProvider
{
    public class OracleProcedureCodeProvider : ProcedureCodeProviderBase
    {
        public override string ToPropertyName(string parameterName)
        {
            FilterPrefix(ref parameterName);
            return CodeUtility.BlockCaseToPascalCase(parameterName);
        }

        public override string MapClassName(string name)
        {
            name = CodeUtility.FilterOwner(name);
            return CodeUtility.BlockCaseToPascalCase(name);
        }

        protected override string DBTypeToCSType(string dbType)
        {
            return OracleUtility.ToCSType(dbType);
        }

        private void FilterPrefix(ref string parameterName)
        {
            if (string.IsNullOrEmpty(parameterName))
            {
                return;
            }

            string[] removedChars=new string[]{"PI_","PO_","P_","X_"};
            foreach (string removedChar in removedChars)
            {
                if (parameterName.StartsWith(removedChar))
                {
                    parameterName=parameterName.Remove(0, removedChar.Length);
                    return;
                }
            }
        }
    }
}
